
$(document).ready(function ()
{
	var a = 'easeOutElastic';
	if ($('.main-menu li.current').length)
	{
		currentCheck = 1;
		default_left = Math.round($('.main-menu li.current').offset().left - $('.main-menu').offset().left - 5);
		default_top = Math.round($('.main-menu li.current').offset().top - $('.main-menu').offset().top);
		default_width = $('.main-menu li.current').width();
		default_height = $('.main-menu li.current').height()
	} else
	{
		currentCheck = 0;
		default_left = 0;
		default_top = 0;
		default_width = 0;
		default_height = 47;
		$('.main-menu li#lava-elm').css('opacity', '0')
	}
	
	
	$('.main-menu li#lava-elm').stop(false, true).animate({
		top: default_top,
		left: default_left,
		width: default_width,
		height: default_height
	},
	{
		duration: 10
	});
	
	// 鼠标移入
	$('.main-menu li').mouseenter(function () {
		if (!$(this).is('#lava-elm')) {
			elemTop = Math.round($(this).offset().top - $('.main-menu').offset().top);
			elemLeft = Math.round($(this).offset().left - $('.main-menu').offset().left - 5);
			width = $(this).width();
			height = $(this).height();
			$('#lava-elm').stop(false, false).animate({
				top: elemTop,
				left: elemLeft,
				width: width,
				height: height
			},
			{
				duration: 700,
				easing: a
			});
			if (currentCheck == 0) {
				$('.main-menu li#lava-elm').css('opacity', '100')
			}
		}
	});
	
	// 鼠标离开
	$('.main-menu').mouseleave(function ()
	{
		if (currentCheck == 0) {
			$('.main-menu li#lava-elm').css('opacity', '0')
		}
		$('.main-menu li#lava-elm').stop(false, true).animate({
			top: default_top,
			left: default_left,
			width: default_width,
			height: default_height
		},
		{
			duration: 100
		})
	});
	
});
